using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using log4net;
using NETL.Engine.Data;

namespace NETL.Engine.Destination
{
	public abstract class MessageDestinationBase : IMessageDestination
	{
		private string myName;
		private string myDescription;
		private ILog myLogger;

		public event DestinationCompleted Completed;

		[XmlIgnore]
		protected ILog Logger
		{
			get { return myLogger; }
		}

		public string Name
		{
			get { return myName; }
			set { myName = value; }
		}

		public string Description
		{
			get { return myDescription; }
			set { myDescription = value; }
		}

		public MessageDestinationBase()
		{
			myLogger = LogManager.GetLogger(GetType());
		}

		public abstract void Execute(IMessage message);
		public abstract ExecutionResult Test();

		protected void OnCompleted(ExecutionResult result)
		{
			DestinationCompleted tmp = Completed;
			if (tmp != null)
			{
				tmp(this, result);
			}
		}
	}
}
